option(KPEXT_BUILD_GTEST_WITH_CV "kpext library develop googletest full test with opencv" OFF)

if(KPEXT_BUILD_GTEST_WITH_CV)
    include(../OpenCV.cmake)
endif()

project(test)

#  kpext vk context 初始化和释放测试
add_executable(
    vkCtxTest
    vkCtxTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "vkCtxTest")

#  cpu 无符号16内存转换传送测试
add_executable(
    u16CvtTest
    u16CvtTest.cpp
    )
list(APPEND TSTargets "u16CvtTest")

# 一些自定义信号量类测试
add_executable(
    semTest
    semTest.cpp
    )

list(APPEND TSTargets "semTest")

# 32位单通道浮点数，二维缓冲复制
add_executable(
    OpImgCpyF32C1Test
    OpImgCpyF32C1Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgCpyF32C1Test")

# 32位单通道浮点数转双通道

add_executable(
    OpImgCvtF32C1toF32C2Test
    OpImgCvtF32C1toF32C2Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgCvtF32C1toF32C2Test")

# 16位无符号单通道转换为32位单通道浮点数

add_executable(
    OpImgCvtU16C1toF32C1Test
    OpImgCvtU16C1toF32C1Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgCvtU16C1toF32C1Test")

# 32位单通道浮点数转换为16位无符号单通道
add_executable(
    OpImgCvtF32C1toU16C1Test
    OpImgCvtF32C1toU16C1Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgCvtF32C1toU16C1Test")


# 32位单通道浮点数进行按行开窗
add_executable(
    OpImgRWinF32C1Test
    OpImgRWinF32C1Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgRWinF32C1Test")

# 32位双通道浮点数求矢量幅值
add_executable(
    OpImgF32C2MagnitudeTest
    OpImgF32C2MagnitudeTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C2MagnitudeTest")


# 32位双通道浮点数FFT变换
add_executable(
    OpImgF32C2FFTTest
    OpImgF32C2FFTTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C2FFTTest")

# 32位单通道浮点数图像转置
add_executable(
    OpImgF32C1TransposeTest
    OpImgF32C1TransposeTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C1TransposeTest")

# 32位单通道浮点数图像 水平/垂直 翻转
add_executable(
    OpImgF32C1FlipTest
    OpImgF32C1FlipTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C1FlipTest")

# 32位单通道浮点数图像 感兴趣区域提取
add_executable(
    OpImgF32C1ROITest
    OpImgF32C1ROITest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C1ROITest")

# 32位单通道浮点数图像 乘以a -> 阀值-> 幂次方 运算测试
add_executable(
    OpImgF32C1MulPowTest
    OpImgF32C1MulPowTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C1MulPowTest")

# 32位单通道浮点数图像 累计平均操作测试
add_executable(
    OpImgF32C1AverageTest
    OpImgF32C1AverageTest.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgF32C1AverageTest")

# 32位单通道浮点数图像 颜色映射到8位无符号4通道图像测试
add_executable(
    OpImgCMapF32C1U8C4Test
    OpImgCMapF32C1U8C4Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgCMapF32C1U8C4Test")

# 16位无符号单通道重采样为32位单通道浮点数
add_executable(
    OpImgResampleU16C1toF32C1Test
    OpImgResampleU16C1toF32C1Test.cpp
    ../kp_ext/spdlog_custom.cpp
    ../kp_ext/KpExtGP.cpp
    )

list(APPEND TSTargets "OpImgResampleU16C1toF32C1Test")

# 公共包含和链接信息
foreach(t ${TSTargets})
    target_link_libraries(${t} PUBLIC kp_ext_st)
    target_include_directories(${t} PRIVATE kp_ext_st)
    target_link_directories(${t} PRIVATE kp_ext_st)
    target_compile_definitions(${t} PRIVATE KPEXT_DEV_MAIN KPEXT_BARE_SRC)

    target_link_libraries(${t} PUBLIC googletest)
    target_include_directories(${t} PRIVATE googletest)
    target_link_directories(${t} PRIVATE googletest)
endforeach()


#  kp_ext 共享库测试
add_executable(
    KpExtSOTest
    KpExtSOTest.cpp
    )
target_link_libraries(KpExtSOTest PRIVATE kp_ext::kp_ext)
target_include_directories(KpExtSOTest PRIVATE kp_ext::kp_ext)
target_link_directories(KpExtSOTest PRIVATE kp_ext::kp_ext)
target_compile_definitions(KpExtSOTest PRIVATE kp_ext::kp_ext)

target_link_libraries(KpExtSOTest PRIVATE fmt::fmt)
target_include_directories(KpExtSOTest PRIVATE fmt::fmt)
target_link_directories(KpExtSOTest PRIVATE fmt::fmt)

target_link_libraries(KpExtSOTest PRIVATE googletest)
target_include_directories(KpExtSOTest PRIVATE googletest)
target_link_directories(KpExtSOTest PRIVATE googletest)

if(KPEXT_BUILD_GTEST_WITH_CV)
    target_link_libraries(KpExtSOTest PRIVATE OpenCV::OpenCV)
    target_include_directories(KpExtSOTest PRIVATE OpenCV::OpenCV)
    target_compile_definitions(KpExtSOTest PRIVATE USE_OPEN_CV)
endif()

#get_target_property(VAR kp_ext_Test COMPILE_DEFINITIONS)
#message("kp_ext_Test COMPILE_DEFINITIONS = ${VAR}")

#################  安装设置  #############

foreach(t ${TSTargets})
    install(TARGETS ${t} RUNTIME DESTINATION bin)
endforeach()

install(TARGETS KpExtSOTest RUNTIME DESTINATION bin)
